<template>
	<view>
		<textarea class="inputinfo" v-model="inputvalues" maxlength=2048></textarea>
		<button class="btn" type="primary" @click="submitData">发布</button>
	</view>
</template>

<script>
	import {request} from"@/api/request.js"
	export default {
		data() {
			return {
				inputvalues: ''
			};
		},
		onLoad() {
			
			
		},
		methods: {
			submitData(){
				// console.log(this.inputvalues)
				if (this.inputvalues){
					var data = {content:this.inputvalues}
					var res = request({
						url: '/leavemsg/LeaveMsg',
						method:'POST',
						data:data
					}).then(res =>{
						// console.log(res)
						if (res.code == 1){
							// console.log(res)
							// 用navigateBack数据不刷新
							// uni.navigateBack({
							// 	delta: 1
							// });
							uni.navigateTo({
								url:'/pages/leavemsg/leavemsg'
							})
						}
					})
				}else
				{
					uni.showToast({
						title: '请输入内容！',
						duration: 2000,
						icon:'error'
					});
				}
				
				
				// uni.navigateTo({
				// 	url:'/pages/addmsg/addmsg'
				// })
			}
		}
	}
</script>

<style lang="scss">
	.inputinfo{
		width: 90%;
		height: 500rpx;
		margin: auto;
		background-color: white;
		margin-top: 20rpx;
	}
	.btn{
		width: 90%;
		margin-top: 50rpx;
	}
</style>
